using System;
using System.Collections;
using System.Drawing;
using System.Drawing.Drawing2D;
using Camalon.Drawing;
using Camalon.Drawing.Shapes;

using System.ComponentModel.Design;

namespace Camalon.Drawing.Design
{
	/// <summary>
	/// Summary description for BezierAdornment.
	/// </summary>
	public class BezierAdornment:ShapeAdornment
	{
		public BezierAdornment( Bezier bezier, ISelectionService selectionService ):base( bezier, selectionService)
		{
		}

		protected override void DrawEditPoints(Graphics g, bool primary, GraphicsPath[] editPointPaths)
		{
			Bezier bezier = base.Shape as Bezier;

			if( bezier == null) return;

			Point[] pts = bezier.ToPoints();// bezier.Points;
			int rem = int.MaxValue; 
			Math.DivRem( bezier.Rotation, 360, out rem ); 
			if( rem != 0 )
				using(Matrix m = new Matrix())
				{
					PointF anchor = bezier.GetRotatingPoint();
					m.RotateAt(bezier.Rotation, anchor, MatrixOrder.Append);

					m.TransformPoints( pts );
				}

			g.DrawLines( Pens.LightGray,pts); 

			base.DrawEditPoints (g, primary, editPointPaths);
		}

	}
}
